// 密码一致性检查
function checkPasswordMatch() {
    const password = document.getElementById('password').value;
    const confirmPassword = document.querySelector('input[name="confirmPassword"]');
    if (password !== confirmPassword.value) {
        confirmPassword.setCustomValidity('密码不匹配');
        confirmPassword.classList.add('is-invalid');
    } else {
        confirmPassword.setCustomValidity('');
        confirmPassword.classList.remove('is-invalid');
    }
}

// 表单提交拦截
document.getElementById('registerForm').addEventListener('submit', function(e) {
    if (!this.checkValidity()) {
        e.preventDefault();
        Swal.fire('错误', '请检查表单填写是否正确', 'error');
    }
});